/**
 * 2019年3月13日 上午10:25:59  
 * richest-api  
 * @author zhaohongchao
 * @version 1.0
 * FoodOrderServiceImpl.java  
 */
package com.richest.api.service.impl;

import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.richest.api.dao.FoodOrderMapper;
import com.richest.api.service.IFoodOrderService;
import com.richest.bean.FoodOrderBean;

/**
 * 2019年3月13日 上午10:25:59 richest-api
 * 
 * @author zhaohongchao
 * @version 1.0 FoodOrderServiceImpl.java
 */
@Service
public class FoodOrderServiceImpl implements IFoodOrderService {

	@Autowired
	private FoodOrderMapper foodOrderMapper;

	@Override
	public void insert(FoodOrderBean foodOrderBean) {
		foodOrderMapper.insert(foodOrderBean);
	}

	@Override
	public void applyRefundOrder(List<Map<String, String>> list, String userId, Integer status, String status_name) {
		for (Map<String, String> map : list) {
			FoodOrderBean foodOrderBean = new FoodOrderBean();
			foodOrderBean.setFood_serial_number(map.get("food_serial_number"));
			foodOrderBean.setReason(map.get("reason") == null ? "" : map.get("reason"));
			foodOrderBean.setStatus(status);
			foodOrderBean.setStatus_name(status_name);
			foodOrderBean.setUpdate_time(new Date());
			foodOrderBean.setUpdate_by(userId);
			foodOrderMapper.update(foodOrderBean);
		}
	}

	@Override
	public List<String> selectFoodSerialNumberByFoodId(String foodId, String eatSerialNumber, Integer count) {
		return foodOrderMapper.selectFoodSerialNumberByFoodId(foodId, eatSerialNumber, count);
	}

	@Override
	public Collection<FoodOrderBean> selectByEatSerialNumber(String eatSerialNumber) {
		return foodOrderMapper.selectByEatSerialNumber(eatSerialNumber);
	}

}
